package servlet;

import bean.Result;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/exituser.s")
public class ExitServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        final HttpSession session = req.getSession();

////        session.removeAttribute("user");
////        session.removeAttribute("useid");
//        session.invalidate();
//        Result result;
//        result=new Result(1,"删除成功",null);
//        final String json = new Gson().toJson(result);
//        resp.getWriter().append(json);
        HttpSession session = req.getSession();
        session.invalidate();
        resp.sendRedirect("index.html");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
